package com.itlong.cloud.service.impl;

import com.itlong.cloud.POJO.PO.DeviceBusinessEntranceChangeLogPO;
import com.itlong.cloud.dao.ICloudEntranceChangeBusinessDao;
import com.itlong.cloud.service.ICloudEntranceChangeBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <desc>
 *      云门禁设备服务管理接口实现类
 * </desc>
 *
 * @createDate 2019/02/27
 */
@Service
public class CloudEntranceChangeBusinessServiceImpl implements ICloudEntranceChangeBusinessService {

    @Autowired
    private ICloudEntranceChangeBusinessDao iCloudEntranceChangeBusinessDao;

    /**
     * <desc>
     *      根据房间ID查询对应的楼栋与单元ID
     * </desc>
     *
     * @param roomId 房间ID
     * @return 楼栋与单元ID
     * @author wangzhi
     * @createDate 2019/02/27
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public String deviceChangeLogGetBuildAndUnitIdByRoomId(String roomId) throws Exception {
        return iCloudEntranceChangeBusinessDao.deviceChangeLogGetBuildAndUnitIdByRoomId(roomId);
    }

    /**
     * <desc>
     *      云门禁_批量保存设备端推送指令
     * </desc>
     *
     * @param deviceBusinessEntranceChangeLogPOS 待保存的参数集
     * @author wangzhi
     * @createDate 2019/02/27
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public Integer saveDeviceBusinessChangeLogBatch(List<DeviceBusinessEntranceChangeLogPO> deviceBusinessEntranceChangeLogPOS) throws Exception{
        if (deviceBusinessEntranceChangeLogPOS != null && deviceBusinessEntranceChangeLogPOS.size() > 0) {
            return iCloudEntranceChangeBusinessDao.saveDeviceBusinessChangeLogBatch(deviceBusinessEntranceChangeLogPOS);
        }
        return 0;
    }
}
